#include "HudRadar.h"

HudRadar g_pHudRadar;

void HudRadar::Init()
{
	Active = true;
	BYTE first[] = {0xA1, 0x00, 0x00, 0x00, 0x00, 0x85, 0xC0, 0x74, 0x06, 0x05};
	FirstOffset = *(DWORD*) (FindPattern::Find((DWORD) GetModuleHandleA(/*client.dll*/XorStr(10, 0xEE, 0x8D01850E, 0x841DC603, 0x8A090000).c_str()), 0x89B000, first, /*x????xxxxx*/XorStr(10, 0x25, 0x5D9B1C9D, 0x1ED867E6, 0x65E40000).c_str()) + 1);
	
	BYTE second[] = {0x8A, 0x84, 0x37, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x5E, 0x5D, 0xC2, 0x04, 0x00};
	SecondOffset = *(DWORD*) (FindPattern::Find((DWORD) GetModuleHandleA(/*client.dll*/XorStr(10, 0xEE, 0x8D01850E, 0x841DC603, 0x8A090000).c_str()), 0x89B000, second, /*xxx????xxxxxx*/XorStr(13, 0x1C, 0x64E362A6, 0x27A829ED, 0x6CEB6AE9, 0x68000000).c_str()) + 3);
}

void HudRadar::Enable()
{
	this->Active = true;
}

void HudRadar::Disable()
{
	this->Active = false;
}

void HudRadar::Set( bool Active )
{
	this->Active = Active;
}

void HudRadar::Compute()
{
	if (Active)
	{
		if (*(DWORD*)FirstOffset)
		{
			BYTE* Players = (BYTE*) (*(DWORD*)FirstOffset + SecondOffset);
			for (int i = 0; i < 32; i++)
			{
				Players[i] = 1;
			}
		}
	}
}
